<?php

if (!defined('TS_ROOT')) die(basename(__FILE__));

$ts_cfg = $page_cfg = array();

// Increase number after changing js or css
$ts_cfg['javascript_ver'] = $ts_cfg['css_ver'] = 1;

// Primary domain name
$domain_name = 'localhost'; // enter here your primary domain name of your site
$domain_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : $domain_name;

// Version ts
$ts_cfg['ts_version'] = 'R21';
$ts_cfg['ts_release_date'] = '14-05-2015';
$ts_cfg['ts_release_state'] = 'DEV';

// Database
$charset  = 'utf8';
$pconnect = false;

// настройка конекта к базе данных
$ts_cfg['db'] = array(
	'db1' => array('localhost', 'test', 'root', '', $charset, $pconnect),
	//'db2' => array('localhost2', 'dbase2', 'user2', 'pass2', $charset, $pconnect),
	//'db3' => array('localhost3', 'dbase3', 'user2', 'pass3', $charset, $pconnect),
);

$ts_cfg['db_alias'] = array(
//	'alias'  => 'srv_name'
);

// Cache
$ts_cfg['cache']['pconnect'] = true;
$ts_cfg['cache']['db_dir']   = realpath(TS_ROOT) .'/internal_data/cache/filecache/';
$ts_cfg['cache']['prefix']   = 'pp_';  // Префикс кеша ('pp_')
$ts_cfg['cache']['memcache'] = array(
	'host'         => '127.0.0.1',
	'port'         => 11211,
	'pconnect'     => true,
	'con_required' => true,
);
$ts_cfg['cache']['redis']  = array(
	'host'         => '127.0.0.1',
	'port'         => 6379,
	'con_required' => true,
);

// Available cache types: memcache, sqlite, redis, apc, xcache (default of filecache)
# name => array( (string) type, (array) cfg )
$ts_cfg['cache']['engines'] = array(
	'ts_cache'      => array('filecache', array()),
	'ts_config'     => array('filecache', array()),
	'session_cache' => array('filecache', array()),
	'ts_cap_sid'    => array('filecache', array()),
	'ts_login_err'  => array('filecache', array()),
	'ts_poll_data'  => array('filecache', array()),
);
// Datastore
// Available datastore types: memcache, sqlite, redis, apc, xcache  (default filecache)
$ts_cfg['datastore_type'] = 'filecache';

// Cloudflare
if (isset($_SERVER['HTTP_CF_CONNECTING_IP']))
{
	$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
}

// Server
$ts_cfg['server_name'] = $domain_name;                                                     // The domain name from which this board runs
$ts_cfg['server_port'] = (!empty($_SERVER['SERVER_PORT'])) ? $_SERVER['SERVER_PORT'] : 80; // The port your server is running on
$ts_cfg['script_path'] = '/';                                                              // The path where FORUM is located relative to the domain name

// GZip
$ts_cfg['gzip_compress']      = true;              // compress output

// Path (trailing slash '/' at the end: PATH - without, DIR - with)
define('PATH',       	realpath(TS_ROOT)                 );
define('ADMIN_DIR',     PATH .'/admin/'                   );
define('DATA_DIR',      PATH .'/data/'                    );
define('INT_DATA_DIR',  PATH .'/internal_data/'           );
define('CACHE_DIR',     PATH .'/internal_data/cache/'     );
define('LOG_DIR',       PATH .'/internal_data/log/'       );
define('TRIGGERS_DIR',  PATH .'/internal_data/triggers/'  );
define('AJAX_DIR',      PATH .'/library/ajax/'            );
define('CFG_DIR',       PATH .'/library/config/'          );
define('INC_DIR',       PATH .'/library/includes/'        );
define('USER_DIR',		PATH .'/library/includes/user/'	  );
define('CORE_DIR',      PATH .'/library/includes/core/'   );
define('CLASS_DIR',     PATH .'/library/includes/classes/');
define('LANG_ROOT_DIR', PATH .'/library/language/'        );
define('IMAGES_DIR',    PATH .'/styles/images/'           );
define('TEMPLATES_DIR', PATH .'/styles/templates/'        );

// Debug
define('COOKIE_DBG',           'ts_dbg'); // debug cookie name
define('SQL_DEBUG',            true);     // enable forum sql & cache debug
define('SQL_LOG_ERRORS',       true);     // all SQL_xxx options enabled only if SQL_DEBUG == TRUE
define('SQL_CALC_QUERY_TIME',  true);     // for stats
define('SQL_LOG_SLOW_QUERIES', true);     // log sql slow queries
define('SQL_SLOW_QUERY_TIME',  10);       // slow query in seconds
define('SQL_PREPEND_SRC_COMM', false);    // prepend source file comment to sql query

$ts_cfg['show_ads'] = false;
// Special users
$ts_cfg['dbg_users'] = array(
#	user_id => 'name',
	2 => 'admin',
);
$ts_cfg['unlimited_users'] = array(
#	user_id => 'name',
	2 => 'admin',
);
$ts_cfg['super_admins'] = array(
#	user_id => 'name',
	2 => 'admin',
);

// Cookie
$ts_cfg['cookie_domain'] = in_array($domain_name, array(getenv('SERVER_ADDR'), 'localhost')) ? '' : ".$domain_name";
$ts_cfg['cookie_secure'] = (!empty($_SERVER['HTTPS']) ? 1 : 0);
$ts_cfg['cookie_prefix'] = 'ts_'; // 'bb_'

// Sessions
$ts_cfg['session_update_intrv']    = 180;          // sec
$ts_cfg['user_session_duration']   = 1800;         // sec
$ts_cfg['admin_session_duration']  = 6*3600;       // sec
$ts_cfg['user_session_gc_ttl']     = 1800;         // number of seconds that a staled session entry may remain in sessions table
$ts_cfg['session_cache_gc_ttl']    = 1200;         // sec
$ts_cfg['max_last_visit_days']     = 14;           // days
$ts_cfg['last_visit_update_intrv'] = 3600;         // sec

// Registration
$ts_cfg['invalid_logins']          = 5;            // Количество неверных попыток ввода пароля, перед выводом проверки капчей
$ts_cfg['new_user_reg_disabled']   = false;        // Запретить регистрацию новых учетных записей
$ts_cfg['unique_ip']               = false;        // Запретить регистрацию нескольких учетных записей с одного ip
$ts_cfg['new_user_reg_restricted'] = false;        // Ограничить регистрацию новых пользователей по времени с 01:00 до 17:00
$ts_cfg['reg_email_activation']    = false;         // Требовать активацию учетной записи по email
$ts_cfg['color_nick'] = true;

// BLOG
$ts_cfg['blog_enabled'] = true;
$ts_cfg['blog_max_count_show'] = 10;
$ts_cfg['max_show_blog_title'] = 50;

// Email
$ts_cfg['emailer_disabled']        = false;

$ts_cfg['smtp_delivery']           = false; // send email via a named server instead of the local mail function
$ts_cfg['smtp_ssl']                = false; // use ssl connect
$ts_cfg['smtp_host']               = '';    // SMTP server host
$ts_cfg['smtp_port']               = 25;    // SMTP server port
$ts_cfg['smtp_username']           = '';    // enter a username if your SMTP server requires it
$ts_cfg['smtp_password']           = '';    // enter a password if your SMTP server requires it

$ts_cfg['board_email']             = "noreply@$domain_name"; // admin email address
$ts_cfg['board_email_form']        = false;        // can users send email to each other via board
$ts_cfg['board_email_sig']         = '';           // this text will be attached to all emails the board sends
$ts_cfg['board_email_sitename']    = $domain_name; // sitename used in all emails header

$ts_cfg['tech_admin_email']        = "admin@$domain_name"; // email for sending error reports
$ts_cfg['abuse_email']             = "abuse@$domain_name";
$ts_cfg['adv_email']               = "adv@$domain_name";

$ts_cfg['use_posts_cache']       = true;  
$ts_cfg['max_search_words_per_post']  = 200;
$ts_cfg['search_min_word_len']        = 3;
$ts_cfg['search_max_word_len']        = 35;
$ts_cfg['spam_filter_file_path']      = '';        // BB_PATH .'/misc/spam_filter_words.txt';
$ts_cfg['ext_link_new_win']       = true;          // open external links in new window

$ts_cfg['poll_max_days']          = 180; // сколько дней с момента создания темы опрос будет активным

// Debug
define('DBG_LOG',              false);    // enable forum debug (off on production)
define('COOKIE_DBG',           'bb_dbg'); // debug cookie name
define('SQL_DEBUG',            true);     // enable forum sql & cache debug
define('SQL_LOG_ERRORS',       true);     // all SQL_xxx options enabled only if SQL_DEBUG == TRUE
define('SQL_CALC_QUERY_TIME',  true);     // for stats
define('SQL_LOG_SLOW_QUERIES', true);     // log sql slow queries
define('SQL_SLOW_QUERY_TIME',  10);       // slow query in seconds
define('SQL_PREPEND_SRC_COMM', false);    // prepend source file comment to sql query

// Language
$ts_cfg['charset']       = 'utf8'; // page charset
$ts_cfg['auto_language'] = true;   // select user-preferred language automatically

if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) && $ts_cfg['auto_language'])
{
	$user_lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
	if (file_exists(LANG_ROOT_DIR . $user_lang .'/'))
	{
		$ts_cfg['default_lang_dir'] = LANG_ROOT_DIR . $user_lang .'/';
		$ts_cfg['default_lang'] = $user_lang;
	}
	else
	{
		$ts_cfg['default_lang_dir'] = LANG_ROOT_DIR .'ru/';
		$ts_cfg['default_lang'] = 'ru';
	}
}
else
{
	if (isset($ts_cfg['default_lang']) && file_exists(LANG_ROOT_DIR . $ts_cfg['default_lang'] .'/'))
	{
		$ts_cfg['default_lang_dir'] = LANG_ROOT_DIR . $ts_cfg['default_lang'] .'/';
	}
	else
	{
		$ts_cfg['default_lang_dir'] = LANG_ROOT_DIR .'ru/';
	}
}

$ts_cfg['lang'] = array(
	'ru' => array(
		'name'     => 'Русский',
		'locale'   => 'ru_RU.UTF-8',
		'encoding' => 'UTF-8',
		'captcha'  => 'ru',
	),
	'ua' => array(
		'name'     => 'Український',
		'locale'   => 'uk_UA.UTF-8',
		'encoding' => 'UTF-8',
		'captcha'  => 'uk',
	),
	'en' => array(
		'name'     => 'English',
		'locale'   => 'en_US.UTF-8',
		'encoding' => 'UTF-8',
		'captcha'  => 'en',
	),
);


$ts_cfg['translate_dates'] = true; // in displaying time

$ts_cfg['last_visit_date_format'] = 'd-M H:i';
$ts_cfg['use_word_censor'] = true;

// Tidy
$ts_cfg['tidy_post'] = (!in_array('tidy', get_loaded_extensions())) ? false : true;

// Templates
define('ADMIN_TPL_DIR', TEMPLATES_DIR .'/admin/');

$ts_cfg['templates'] = array(
//	'folder'  => 'Name',
	'default' => 'Стандартный',
);

$ts_cfg['tpl_name'] = 'default';
$ts_cfg['stylesheet'] = 'bootstrap.css';

$ts_cfg['login_url'] = 'login.php';
$ts_cfg['blog_url'] = 'blog.php';
$ts_cfg['ajax_url'] = 'ajax.php';

define('GZIP_OUTPUT_ALLOWED', (extension_loaded('zlib') && !ini_get('zlib.output_compression')));

// Log options
define('LOG_EXT',      'log');
define('LOG_SEPR',     ' | ');
define('LOG_LF',       "\n");
define('LOG_MAX_SIZE', 1048576); // bytes

// Error reporting
ini_set('error_reporting', E_ALL);
ini_set('display_errors',  0);
ini_set('log_errors',      1);
ini_set('error_log',       LOG_DIR .'ts_errors.log');

// Check some variable
// Magic quotes
if (get_magic_quotes_gpc()) die('Set magic_quotes off');
// JSON
if (!function_exists('json_encode')) die('Json_encode not installed');

// Triggers
define('TS_ENABLED',   TRIGGERS_DIR .'$on');
define('TS_DISABLED',  TRIGGERS_DIR .'$off');
define('CRON_ALLOWED', TRIGGERS_DIR .'cron_allowed');
define('CRON_RUNNING', TRIGGERS_DIR .'cron_running');

// Date format
$ts_cfg['date_format']             = 'Y-m-d';

$ts_cfg['terms_and_conditions_url'] = 'terms.php';

$ts_cfg['user_agreement_url']       = 'info.php?show=user_agreement';
$ts_cfg['copyright_holders_url']    = 'info.php?show=copyright_holders';
$ts_cfg['advert_url']               = 'info.php?show=advert';

// Extensions
$ts_cfg['file_id_ext'] = array(
	1 => 'gif',
	2 => 'gz',
	3 => 'jpg',
	4 => 'png',
	5 => 'rar',
	6 => 'tar',
	7 => 'tiff',
	8 => 'zip',
);

// Captcha
// Get a Google reCAPTCHA API Key: https://www.google.com/recaptcha/admin
$ts_cfg['captcha'] = array(
	'disabled'   => false,
	'public_key' => '6Le37P4SAAAAAK5Kuc3OQ-jRs0t6_NcxPZ7yeFWV', // your public key
	'secret_key' => '6Le37P4SAAAAALpvdMlrb2Z_Ejt73o1j48t7UGER', // your secret key
	'theme'      => 'light', // light or dark
);

// Avatars
$ts_cfg['avatars'] = array(
	'allowed_ext' => array('gif','jpg','jpeg','png'), // разрешенные форматы файлов
	/*'bot_avatar'  => 'gallery/bot.gif',    */           // аватара бота
	'max_size'    => 100*1024,                        // размер аватары в байтах
	'max_height'  => 100,                             // высота аватара в px
	'max_width'   => 100,                             // ширина аватара в px
	'no_avatar'   => TS_ROOT . 'noavatar.png',          // дефолтная аватара
	'upload_path' => TS_ROOT . 'data/avatars/',       // путь к директории с аватарами
	'up_allowed'  => true,                            // разрешить загрузку аватар
);

// Nofollow
$ts_cfg['nofollow'] = array(
	'disabled'    => false,
	'allowed_url' => array($domain_name),             // 'allowed.site', 'www.allowed.site'
);

define('TS_CFG_LOADED', true);